package cn.edu.scau.cmi.yangzhichao.client;
import cn.edu.scau.cmi.yangzhichao.FinalExam.FinalExamViewController;
import cn.edu.scau.cmi.yangzhichao.abstractFactory.InsuranceView3Controller;
import cn.edu.scau.cmi.yangzhichao.adapter.AdapterViewController;
import cn.edu.scau.cmi.yangzhichao.composite.consistent.ConsistentCompositeViewController;
import cn.edu.scau.cmi.yangzhichao.composite.safe.SafeCompositeViewController;
import cn.edu.scau.cmi.yangzhichao.factory.InsuranceView2Controller;
import cn.edu.scau.cmi.yangzhichao.singleton.*;
import cn.edu.scau.cmi.yangzhichao.multipleton.*;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class FinalExamClient extends Application {
    private Stage primaryStage;
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage=primaryStage;
        this.primaryStage.setTitle("FinalExam");
        showView();
    }
    public void showView(){
        try{
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(FinalExamViewController.class.getResource("FinalExamView.fxml"));
            AnchorPane anchorPane=(AnchorPane) loader.load();
            Scene scene=new Scene(anchorPane);
            primaryStage.setScene(scene);
            FinalExamViewController controller=loader.getController();
            controller.setClient(this);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView1(){
        try{
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(ChairManViewController.class.getResource("ChairManView.fxml"));
            AnchorPane anchorPane=(AnchorPane)loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("单例模式");
            primaryStage.setScene(scene);
            ChairManViewController ChairManViewController=loader.getController();
            ChairManViewController.setDialogStage(primaryStage);
            primaryStage.showAndWait();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView2(){
        try{
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(BasketBallerViewController.class.getResource("BasketBallerView.fxml"));
            AnchorPane anchorPane=(AnchorPane)loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("多例模式");
            primaryStage.setScene(scene);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public void showView4(){
        try{
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(InsuranceView2Controller.class.getResource("InsuranceView2.fxml"));
            AnchorPane anchorPane=(AnchorPane) loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("工厂模式");
            primaryStage.setScene(scene);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView5(){
        try{
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(InsuranceView3Controller.class.getResource("InsuranceView3.fxml"));
            AnchorPane anchorPane=(AnchorPane) loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("抽象工厂模式");
            primaryStage.setScene(scene);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView6(){
        try {
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(AdapterViewController.class.getResource("AdapterView.fxml"));
            AnchorPane anchorPane=(AnchorPane)loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("适配器模式");
            primaryStage.setScene(scene);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView7(){
        try {
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(SafeCompositeViewController.class.getResource("SafeCompositeView.fxml"));
            AnchorPane anchorPane=(AnchorPane)loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("安全组合模式");
            primaryStage.setScene(scene);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public void showView8(){
        try {
            FXMLLoader loader=new FXMLLoader();
            loader.setLocation(ConsistentCompositeViewController.class.getResource("ConsistentCompositeView.fxml"));
            AnchorPane anchorPane=(AnchorPane)loader.load();
            Scene scene=new Scene(anchorPane);
            Stage primaryStage=new Stage();
            primaryStage.setTitle("一致性组合模式");
            primaryStage.setScene(scene);
            primaryStage.setResizable(false);
            primaryStage.show();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
